# 用上节课torchvision提供的自定义的数据集
# CIFAR10原本是PIL Image，需要转换成tensor

import torchvision.datasets
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter

# 准备的测试数据集
test_data = torchvision.datasets.CIFAR10("./dataset", train=False, transform=torchvision.transforms.ToTensor())

# 加载测试集
test_loader = DataLoader(dataset=test_data, batch_size=9, shuffle=True, num_workers=0, drop_last=False)
# batch_size=4，意味着每次从test_data中取4个数据进行打包

writer = SummaryWriter("dataloader")
step = 0
for data in test_loader:
    imgs, targets = data  # imgs是tensor数据类型
    writer.add_images("test_data_1", imgs, step)
    step = step + 1
writer.close()
